package com.ktjy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktjy.dto.ActivityDTO;
import com.ktjy.mapper.TbActivityMapper;
import com.ktjy.pojo.TbActivity;
import com.ktjy.service.ITbActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
 * <p>
 * 活动管理 服务实现类
 * </p>
 *
 * @author jjx
 * @since 2025-08-02
 */
@Service
public class TbActivityServiceImpl extends ServiceImpl<TbActivityMapper, TbActivity> implements ITbActivityService {
    @Autowired
    TbActivityMapper tbActivityMapper;

    @Override
    public List<TbActivity> findList(ActivityDTO activityDTO) {
        QueryWrapper qw=new QueryWrapper();
        if(!ObjectUtils.isEmpty(activityDTO.getChannel())){
            qw.eq("channel",activityDTO.getChannel());
        }
        if(!ObjectUtils.isEmpty(activityDTO.getStatus())){
            qw.eq("status",activityDTO.getStatus());
        }
        return tbActivityMapper.selectList(qw);
    }

    @Override
    public IPage<TbActivity> findPage(ActivityDTO activityDTO, Integer pageNo, Integer pageSize) {
        //构造分页条件
        Page page=new Page(pageNo,pageSize);
        return tbActivityMapper.selectPage(page,activityDTO);
    }
}
